package com.sk.cardeal.act.home.activity;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.widget.TextView;

import com.sk.cardeal.R;
import com.sk.cardeal.act.home.fragment.CustomCommentFragment;
import com.sk.cardeal.act.home.fragment.PartsDetailsFragment;
import com.sk.cardeal.act.home.fragment.TemporaryFragment;
import com.sk.cardeal.act.home.fragment.VipCustomFragment;
import com.sk.cardeal.adapter.MyPagerAdapter;
import com.sk.cardeal.base.BaseActivity;
import com.sk.cardeal.view.TitleView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by sk on 2017/12/29.
 */

public class PartsDetailsActivity extends BaseActivity {
    @BindView(R.id.title_view)
    TitleView titleView;
    @BindView(R.id.tv_vin)
    TextView tvVin;
    @BindView(R.id.tv_brand)
    TextView tvBrand;
    @BindView(R.id.part_name)
    TextView partName;
    @BindView(R.id.tv_price)
    TextView tvPrice;
    @BindView(R.id.my_table)
    TabLayout myTable;
    @BindView(R.id.my_pager)
    ViewPager myPager;

    PartsDetailsFragment partsDetailsFragment;
    CustomCommentFragment customCommentFragment;
    private List<Fragment> fragmentList = new ArrayList<>();

    @Override
    protected int getContentView() {
        return R.layout.activity_parts_details;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        titleView.setMyCallBack(this);
        initFragments();
    }

    private void initFragments() {

        partsDetailsFragment = new PartsDetailsFragment();
        customCommentFragment = new CustomCommentFragment();

        fragmentList.add(partsDetailsFragment);
        fragmentList.add(customCommentFragment);

        MyPagerAdapter adapter = new MyPagerAdapter(getSupportFragmentManager(), getResources().getStringArray(R.array.part_array), fragmentList);
        myPager.setAdapter(adapter);
        myTable.setupWithViewPager(myPager);

    }


    @Override
    public void clickTitle(int i) {
        super.clickTitle(i);
        switch (i) {
            case 1:
                finish();
                break;
            case 2:
                break;
            case 3:
                break;
        }
    }
}
